<script  lang="ts">
import { IconMyData } from "@/icons";
import { defineAsyncComponent, defineComponent, onMounted, ref } from "vue";

export default defineComponent({
  name: "SystemManage",
  components: {
    IconMyData,
    UserManagement: defineAsyncComponent(
      () => import("@/system-manage/user-mamagement/user-management.vue")
    ),
    ProjectManagement: defineAsyncComponent(
      () => import("@/system-manage/project-management/project-management.vue")
    ),
    ResourceAllocation: defineAsyncComponent(
      () => import("@/system-manage/resource-allocation/index.vue")
    ),
  },
  setup() {
    const dataList = [
      {
        id: 1,
        name: "用户管理",
        icon: "dv dv-shujuku",
        com: "UserManagement",
      },
      {
        id: 2,
        name: "项目管理",
        icon: "dv dv-shujujicheng",
        com: "ProjectManagement",
      },
      {
        id: 3,
        name: "资源配置",
        icon: "dv dv-shujujicheng",
        com: "ResourceAllocation",
      },
      // {
      //   id: 4,
      //   name: "云函数",
      //   icon: "dv dv-daimaji",
      //   com: "DataFilter",
      // },
    ];

    const selectedCom = ref("UserManagement");
    const selected = ref(1);
    const handClickData = (da: any) => {
      selected.value = da.id;
      selectedCom.value = da.com;
    };
    return {
      dataList,
      selectedCom,
      selected,
      handClickData,
    };
  },
});
</script>

<template>
  <div class="datav-sys-manage">
    <n-card title="">
      <template #header>
        <div class="manage-title">
          <div class="my-project project-group">
            <span class="new-project">
              <n-icon class="btn-add-icon">
                <IconMyData />
              </n-icon>
              系统管理
            </span>
          </div>
        </div>
      </template>
      <div class="manage-main">
        <ul>
          <li
            v-for="da in dataList"
            :key="da.id"
            :class="{ 'is-select': da.id === selected }"
            @click.stop="handClickData(da)"
          >
            <i :class="da.icon"></i>
            {{ da.name }}
          </li>
        </ul>
      </div>
    </n-card>
    <div class="main-page">
      <component :is="selectedCom" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
:deep(.n-card-header) {
  padding: 0px !important;
}
:deep(.n-card__content) {
  padding: 0px !important;
}
.datav-sys-manage {
  display: flex;
  height: calc(100% - 10px);
  .n-card {
    border: none;
    background: transparent;
    .manage-title {
      .project-group {
        padding-left: 8px;
        height: 56px;
        display: flex;
        border-bottom: 1px solid #27343e;
        .new-project {
          display: flex;
          align-items: center;
          color: #fff;
          font-size: 16px;
          i {
            margin-right: 4px;
          }
        }
      }

      .btn-add-icon {
        font-size: 14px;
        cursor: pointer;

        &:hover {
          color: var(--datav-main-color);
        }
      }
    }
    .manage-main {
      display: flex;
      flex-direction: column;
      font-size: 12px;
      ul {
        li {
          color: var(--datav-font-color);
          font-size: var(--datav-font-size-base);
          padding-left: 30px;
          padding-top: 10px;
          padding-bottom: 10px;
          margin: 5px 0;
          transition: all 0.25s linear;
          cursor: pointer;

          &:hover {
            color: var(--datav-gui-hover-color);
          }
          &.is-select {
            background-image: url(@/assets/img/data-li-bg.png);
            background-repeat: round;
            color: var(--datav-gui-font-color-1);
          }

          i {
            margin-right: 8px;
          }
        }
      }
    }

    &:first-child {
      width: 240px;
      margin-right: 16px;
      background-color: var(--datav-home-nav-bg);
    }
  }
  .main-page {
    width: calc(100% - 272px);
    height: calc(100% - 38px);
    margin-top: 16px;
    color: var(--datav-gui-font-color-1);
  }
}
</style>

